<template>
    <el-dialog :title="dialogTitle" :visible.sync="visible" :width="width" top="0vh" @closed="beforeClose">
        <SubmitForm ref="singleForm" v-bind="$attrs" :cancel-fun="dialogCancelFun"></SubmitForm>
    </el-dialog>
</template>
<script>
import SubmitForm from './index.vue'
export default {
    components: { SubmitForm },
    inheritAttrs: false,
    props: {
        dialogTitle: String,
        width: {
            type: String,
            default: '800px'
        },
        cancelFun: {
            type: Function,
            default: () => {}
        }
    },
    data() {
        return { visible: false }
    },
    methods: {
        dialogCancelFun(data) {
            this.hide()
            this.cancelFun(data)
        },
        show(data) {
            this.visible = true
        },
        hide() {
            this.visible = false
        },
        beforeClose() {
            this.$refs.singleForm.clear()
        }
    }
}
</script>
